using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;


public static class MyExtensions
{
    public static string GetAttributeValue(this XmlNode node, string attribute)
    {
        var attr = node.Attributes.GetNamedItem(attribute);
        if (attr != null)
        {
            return attr.Value;
        }
        else { return ""; }
    }

    public static string ValueOfIndex(this XmlNodeList nodes, int index)
    {
        var node = nodes[index];
        if (node != null)
        {
            return node.InnerText;
        }
        else
        {
            return "";
        }
    }

    public static string GetCellValueByFirstColumn(this XmlNodeList rows, string header)
    {
        for (int i = 0; i < rows.Count; i++)
        {
            XmlNode Node = rows[i];
            if (Node.ChildNodes.Count > 1) { 
                if (Node.SelectNodes("td[text() = '" + header + "']").Count > 0)
                {
                    return Node.ChildNodes[1].InnerText.Trim();
                }
            }
        }
        return "";
    }
}